package linker

// this file contains apis for output phdr things
import (
	"debug/elf"
	"rvld/src/utils"
)

func NewOutputPhdr() *OutputPhdr {

	o := &OutputPhdr{Chunk: NewChunk()}
	o.Shdr.Flags = uint64(elf.SHF_ALLOC)
	o.Shdr.AddrAlign = 8

	return o
}

func (o *OutputPhdr) UpdateShdr(ctx *Context) {
	o.Phdrs = createPhdr(ctx)
	o.Shdr.Size = uint64(len(o.Phdrs))
}

func (o *OutputPhdr) CopyBuf(ctx *Context) {
	utils.ThisWrite(ctx.Buf[o.Shdr.Offset:], o.Phdrs)
}

// DONE
